cmake_minimum_required(VERSION 3.10)

# 项目名称
project(qt_rtsp_show_ui)

# 设置C/C++标准
set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 设置编译器
set(CMAKE_C_COMPILER gcc)
set(CMAKE_CXX_COMPILER g++)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC 0FF)

# 查找Qt5包
find_package(Qt5 REQUIRED COMPONENTS Core Gui Qml Widgets ) # QT核心图形库
find_package(Qt5 COMPONENTS Network)# QT网络库

# 查找Opencv
find_package(OpenCV REQUIRED)	# 找到opencv库
include_directories(${OpenCV_INCLUDE_DIRS})

# 查找 OpenCL 库
find_package(OpenCL REQUIRED)

# 查找FFmpeg包
find_package(PkgConfig REQUIRED)
pkg_check_modules(AVUTIL REQUIRED libavutil)
pkg_check_modules(AVFORMAT REQUIRED libavformat)
pkg_check_modules(AVCODEC REQUIRED libavcodec)
pkg_check_modules(SWRESAMPLE REQUIRED libswresample)
pkg_check_modules(SWSCALE REQUIRED libswscale)
################################################################################
# 包含目录
include_directories(${Qt5Core_INCLUDE_DIRS}
                    ${Qt5Widgets_INCLUDE_DIRS}
                    ${AVUTIL_INCLUDE_DIRS}
                    ${AVFORMAT_INCLUDE_DIRS}
                    ${AVCODEC_INCLUDE_DIRS}
                    ${SWRESAMPLE_INCLUDE_DIRS}
                    ${SWSCALE_INCLUDE_DIRS})
# 添加头文件搜索路径
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ui)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/model)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/3rdparty)
# 添加model文件夹内的源文件
file(GLOB_RECURSE MODEL_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/model/*.cpp")
file(GLOB_RECURSE NLOHMANN_JSON_LIB "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/nlohmann/json.hpp")
################################################################################
# 添加执行文件
add_executable(run_qt_rtsp_show_ui main.cpp ${MODEL_SOURCES} ${NLOHMANN_JSON_LIB}) # ${UI_HEADERS}

# 链接Qt5和FFmpeg库
target_link_libraries(run_qt_rtsp_show_ui 
    Qt5::Core 
    Qt5::Gui
    Qt5::Widgets
    Qt5::Network
    ${OpenCV_LIBRARIES}
    ${AVUTIL_LIBRARIES}
    ${AVFORMAT_LIBRARIES}
    ${AVCODEC_LIBRARIES}
    ${SWRESAMPLE_LIBRARIES}
    ${SWSCALE_LIBRARIES}
    ${OpenCL_LIBRARIES})
